home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / bfd / seclet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-28  |  2.5 KB  |  130 lines

  1. /* This module is part of BFD */
  2.  
  3.  
  4. /* The intention is that one day, all the code which uses sections
  5.    will change and use seclets instead - maybe seglet would have been
  6.    a better name..
  7.  
  8.    Anyway, a seclet contains enough info to be able to describe an
  9.    area of output memory in one go.
  10.  
  11.    The only description so far catered for is that of the
  12.    <<bfd_indirect_seclet>>, which is a select which points to a
  13.    <<section>> and the <<asymbols>> associated with the section, so
  14.    that relocation can be done when needed.
  15.  
  16.    One day there will be more types - they will at least migrate from
  17.    the linker's data structures - also there could be extra stuff,
  18.    like a bss seclet, which descibes a lump of memory as containing
  19.    zeros compactly, without the horrible SEC_* flag cruft.
  20.  
  21.  
  22. */
  23.  
  24. #include "bfd.h"
  25. #include "sysdep.h"
  26. #include "libbfd.h"
  27. #include "seclet.h"
  28. #include "coff/internal.h"
  29. bfd_seclet_type *
  30. DEFUN(bfd_new_seclet,(abfd, section),
  31.       bfd *abfd AND
  32.       asection *section)
  33. {
  34.   bfd_seclet_type *n = (bfd_seclet_type *)bfd_alloc(abfd, sizeof(bfd_seclet_type));
  35.   if (section->seclets_tail != (bfd_seclet_type *)NULL) {
  36.       section->seclets_tail->next = n;
  37.     }
  38.   else
  39.   {
  40.     section->seclets_head = n;
  41.   }
  42.   section->seclets_tail = n;
  43.  
  44.   return n;
  45.   
  46. }
  47.  
  48.  
  49.  
  50.  
  51. #define MAX_ERRORS_IN_A_ROW 10
  52. extern bfd_error_vector_type bfd_error_vector;
  53.  
  54.  
  55. void
  56. DEFUN(rel,(abfd, seclet, output_section),
  57.       bfd *abfd AND
  58.       bfd_seclet_type *seclet AND
  59.       asection *output_section)
  60. {
  61.   bfd_byte *data;
  62.   if (output_section->flags & SEC_HAS_CONTENTS )
  63.   {
  64.     
  65.   data = bfd_get_relocated_section_contents(abfd, seclet);
  66.  
  67.   if(bfd_set_section_contents(abfd,
  68.                   output_section,
  69.                   data,
  70.                   seclet->offset,
  71.                   seclet->size) == false)
  72.   {
  73.     abort();
  74.   }
  75.   
  76. }
  77.  
  78.     
  79.  
  80.   
  81.  
  82. }
  83.  
  84. void
  85. DEFUN(seclet_dump_seclet,(abfd, seclet, section),
  86.       bfd *abfd AND
  87.       bfd_seclet_type *seclet AND
  88.       asection *section)
  89. {
  90.   switch (seclet->type) 
  91.   {
  92.     
  93.   case bfd_indirect_seclet:
  94.     /* The contents of this section come from another one somewhere
  95.        else */
  96.     rel(abfd, seclet, section);
  97.     
  98.     
  99.     break;
  100.     
  101.   default:
  102.     abort();
  103.   }
  104.   
  105.  
  106.  
  107. }
  108.  
  109. void
  110. DEFUN(seclet_dump,(abfd),
  111.       bfd *abfd)
  112. {
  113.   /* Write all the seclets on the bfd out, relocate etc according to the
  114.      rules */
  115.  
  116.   asection *o = abfd->sections;
  117.   while (o != (asection *)NULL) 
  118.   {
  119.     bfd_seclet_type *p = o->seclets_head;
  120.     while (p != (bfd_seclet_type *)NULL) 
  121.     {
  122.       seclet_dump_seclet(abfd, p, o);
  123.       p = p ->next;
  124.     }
  125.  
  126.     o = o->next;
  127.   }
  128.  
  129. }
  130.